package cq.zhcqk.util;

import android.content.Context;
import android.content.SharedPreferences;

/**
 * Created by zhangle on 2017/5/29.
 */
public class SharedPreferencesHelper {

    public static void saveSp(Context context,String key,String value){
        SharedPreferences sp = context.getSharedPreferences("AV666", Context.MODE_PRIVATE);
        sp.edit().putString(key, value).commit();
    }

    public static SharedPreferences getSp(Context context){
        SharedPreferences sp = context.getSharedPreferences("AV666", Context.MODE_PRIVATE);
        return sp;
    }

    /**
     * 是否第一次启动
     * @param context
     * @return
     */
    public static boolean isFirst(Context context){
        SharedPreferences sharedPreferences = context.getSharedPreferences("share", Context.MODE_PRIVATE);

        boolean isFirstRun = sharedPreferences.getBoolean("isFirstRun", true);
        SharedPreferences.Editor editor = sharedPreferences.edit();

        if (isFirstRun){
            editor.putBoolean("isFirstRun", false);
            editor.commit();
        } else {

        }
        return isFirstRun;
    }
}
